<div class="layuimini-container layuimini-page-anim" style="height: 100%">
    <!--原始柱状图-->
       <!-- <div class="layui-row layui-col-space15">
            <div class="layui-col-xs12 layui-col-md6">
                <div id="echarts-dataset" style="background-color:#ffffff;min-height:1000px;min-width:1000px;padding: 10px"></div>
            </div>
        </div>-->


      <div id="container" style="height: 50%;width: 80%"></div>
      <div id="Rose" style="height: 50%"></div>


</div>
<!--<script>
    layui.use(['layer','echarts'], function () {
        var $ = layui.jquery,
            layer = layui.layer,
            echarts = layui.echarts;
        /**
         * 柱状图及其数据初始化
         */
        var myCharts;
        $.ajax({
             url:"/expenditure",
             data:{},
             dataType:"json",
             success:function (data) {
                 if(data != null){
                     /*初始化柱状图(确定柱状图在哪个元素上生成)*/
                     myCharts = echarts.init(document.getElementById('echarts-dataset'), 'walden');
                     /*后台返回的JSON数据echarts无法直接解析，需要转换一下*/
                     /*var dataset = $.parseJSON(data);*/
                     var dataset = data;
                     console.log(dataset);
                     var optionDataset = {
                         title: {
                             text:'鑫豪斯2020年税务报表(注：单位是万元哦)',
                             left:'center',
                             top:'top',
                         },
                         legend: {data:['税额']},
                         tooltip: {},
                         /* dataset: {
                              dimensions: ['product', '2015', '2016', '2017'],
                              source: [
                                  {product: 'Matcha Latte', '2015': 43.3, '2016': 85.8, '2017': 93.7},
                                  {product: 'Milk Tea', '2015': 83.1, '2016': 73.4, '2017': 55.1},
                                  {product: 'Cheese Cocoa', '2015': 86.4, '2016': 65.2, '2017': 82.5},
                                  {product: 'Walnut Brownie', '2015': 72.4, '2016': 53.9, '2017': 39.1}
                              ]
                          },*/
                         xAxis: {data:['1月','2月','3月','4月','5月',
                                 '6月','7月','8月','9月','10月']},
                         yAxis: {},
                         // Declare several bar series, each will be mapped
                         // to a column of dataset.source by default.
                         series: [{
                             name: '鑫豪斯',
                             type: 'bar',
                             data: dataset
                         }]
                     };
                     myCharts.setOption(optionDataset);
                 }
             },
            error:function (errorMsg) {
               layui.msg("服务器开了点小差，请重新刷新试试，给你带来不便请谅解!!",{icon:0});
                myCharts.hideLoading();
            }
        });

        // echarts 窗口缩放自适应
        window.onresize = function () {
            echartsRecords.resize();
        }

    });
</script>-->

<!--更好看的柱状图-->
<script type="text/javascript">
    $(function () {
        /*柱状图*/
        $.ajax({
            url:"/expenditure",
            data:{},
            dataType:"json",
            success:function (data){
                var dom = document.getElementById("container");
                var myChart = echarts.init(dom);
                var app = {};
                option = null;
                var datapaytaxes = data;
                var dataprofit =null ;
                option = {
                    title: {
                        text: '鑫豪斯2020年税务报表(注：单位是万元哦)'
                    },
                    legend: {
                        data: ['税额']
                    },
                    toolbox: {
                        // y: 'bottom',
                        feature: {
                            magicType: {
                                type: ['stack', 'tiled']
                            },
                            dataView: {},
                            saveAsImage: {
                                pixelRatio: 2
                            }
                        }
                    },
                    tooltip: {},
                    xAxis: {
                        data:['1月','2月','3月','4月','5月',
                            '6月','7月','8月','9月','10月'],
                        splitLine: {
                            show: false
                        }
                    },
                    yAxis: {
                    },
                    series: [{
                        name: '税额',
                        type: 'bar',
                        data: datapaytaxes,
                        animationDelay: function (idx) {
                            return idx * 10;
                        }
                    }],
                    animationEasing: 'elasticOut',
                    animationDelayUpdate: function (idx) {
                        return idx * 5;
                    }
                };;
                if (option && typeof option === "object") {
                    myChart.setOption(option, true);
                }
            }
        });
        /*玫瑰饼图*/
        $.ajax({
            url:"/jiduexpenditure",
            data:{},
            dataType:"json",
            success:function (data){
                var dom = document.getElementById("Rose");
                var myChart = echarts.init(dom);
                var app = {};
                var dataset = data;
                console.log(dataset);
                option = null;
                option = {
                    title: {
                        text: '鑫豪斯季度税额统计',
                        subtext: '单位依然是万元',
                    },
                    tooltip: {
                        trigger: 'item',
                        formatter: '{a} <br/>{b} : {c} ({d}%)'
                    },
                    legend: {
                        left: 'center',
                        top: 'bottom',
                        data: ['一季度', '二季度', '三季度', '四季度']
                    },
                    toolbox: {
                        show: true,
                        feature: {
                            mark: {show: true},
                            dataView: {show: true, readOnly: false},
                            magicType: {
                                show: true,
                                type: ['pie', 'funnel']
                            },
                            restore: {show: true},
                            saveAsImage: {show: true}
                        }
                    },
                    series: [
                        {
                            name: '半径模式',
                            type: 'pie',
                            radius: [25, 110],
                            center: ['40%', '50%'],
                            roseType: 'radius',
                            label: {
                                show: false
                            },
                            emphasis: {
                                label: {
                                    show: true
                                }
                            },
                            data: dataset
                        },
                    ]
                };
                if (option && typeof option === "object") {
                    myChart.setOption(option, true);
                }
            }
        });

    });

</script>
